<template>
    <div class="container">
      <div class="tasks">
        <div class="title-box">
          <h3>正在进行</h3>
          <span class="run-count">{{$store.getters.runNum}}</span>
        </div>
        <ul class="running-tasks-box">
        <!-- list 里面是包含 正在进行和已完成的数据 -->
          <template v-for="(item,index) in $store.state.todoList" >
              <!-- item.flag==false 满足这样一个等式 就会返回一个 true -->
            <li class="list-item" v-if="!item.flag" :key="index">
            <div>
              <input type="checkbox" v-model="item.flag"/>
              <span>{{item.msg}}</span>
            </div>
            <div class="del"  @click="$store.commit('del',index)">-</div>
          </li>
          </template>
        </ul>
      </div>
      <div class="tasks">
        <div class="title-box">
          <h3>已经完成</h3>
          <span class="finish-count">{{$store.getters.finishNum}}</span>
        </div>
        <ul class="finish-task-box">
           <template v-for="(item,index) in $store.state.todoList">
            <li class="list-item" v-if="item.flag" :key="index">
            <div>
              <input type="checkbox" v-model="item.flag"/>
              <span>{{item.msg}}</span>
            </div>
            <div class="del" @click="$store.commit('del',index)">-</div>
          </li>
          </template>
        </ul>
      </div>
    </div>
</template>
<style lang="scss" scoped>
.container {
  width: 100%;
}

.tasks {
  width: 600px;
  margin: 0 auto;
  margin-top: 50px;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.title-box {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h3 {
  font-size: 26px;
  font-weight: bold;
}

.title-box span {
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  background-color: #fff;
  border-radius: 20px;
}

.list-item {
  width: 100%;
  height: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fff;
  border-left: 4px solid #629a9c;
  border-radius: 6px;
  padding-left: 10px;
  padding-right: 15px;
  margin-bottom: 20px;
}

.list-item input {
  height: 30px;
  width: 30px;
  vertical-align: middle;
}

.list-item span {
  display: inline-block;
  vertical-align: middle;
}

.del {
  box-sizing: content-box;
  display: inline-block;
  width: 14px;
  height: 12px;
  border-radius: 14px;
  border: 6px double #fff;
  background: #ccc;
  line-height: 14px;
  text-align: center;
  color: #fff;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
}

.finish-task-box {
  opacity: 0.5;
}
</style>
